package com.edu.modules.baseinfo.api;

import com.alibaba.fastjson.JSONObject;
import com.edu.modules.baseinfo.service.WXService;
import com.edu.modules.baseinfo.vo.ResultVo;
import com.sari.common.utils.RequestContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by 王世锋 on 2018-05-11.
 */
@CrossOrigin
@Controller
@RequestMapping(value = "wx")
public class WXApi {

    @Autowired
    private WXService wxService;

    @ResponseBody
    @RequestMapping(value = "saveOpenId")
    public ResultVo saveOpenId(HttpServletRequest request){

        JSONObject param = RequestContextUtils.readJson(request);
        return wxService.saveOpenId(param);
    }

    @ResponseBody
    @RequestMapping(value = "share")
    public JSONObject share(String url){

        return wxService.getShareData(url);
    }

    @ResponseBody
    @RequestMapping(value = "data")
    public JSONObject getWxData(){

        return wxService.getWxData();
    }
}
